Annual emissions broken down by sector
Annual emissions broken down by sector#
Here we can present the visualisations and discuss them.
This page can be easily printed to a pdf using the buttons on the top right hand side of this web page.
This page is just a markdown file that has been slightly adapted to look nicer in Jupyter Books - e.g. removing the cell inputs/ outputs to only show the interactive graph below.
alpha = 0.6
color_ch4 = ["rgba(86, 119, 194, 1)", f"rgba(86, 119, 194, {alpha})"]
color_n2o = ["rgba(99, 182, 137, 1)", f"rgba(99, 182, 137, {alpha})"]
color_fgas = ["rgba(187, 103, 93, 1)", f"rgba(187, 103, 93, {alpha})"]
fig = go.Figure()
mo_logo = base64.b64encode(open("metoffice_logo.png", 'rb').read())
uob_logo = base64.b64encode(open("uob_logo.png", 'rb').read())
def errorbars(df, var, color, dash, name, showlegend=True):
error_minus=df[var] - df[f"{var}_std"]
error_plus=df[var] + df[f"{var}_std"]
fig.add_trace(go.Scatter(
x=df.index,
y=error_minus.values,
fill=None,
mode='lines',
line=dict(color=color[1], width=0.1),
showlegend=False,
hoverinfo='skip'
))
fig.add_trace(go.Scatter(
x=df.index,
y=error_plus.values,
fill="tonexty",
mode='lines',
line=dict(color=color[1], width=0.1),
showlegend=False,
hoverinfo='skip'
))
fig.add_trace(go.Scatter(
x=df.index,
y=df[var],
mode="lines",
line=dict(color=color[0], dash=dash),
showlegend=showlegend,
name=name,
hovertemplate = 'InTEM %{x|%Y}: %{y:.0f} Gt yr⁻¹<extra></extra>',
))
# errorbars(df_ch4.loc[:"2011-01-01"], "InTEM", color_ch4, None, "CH<sub>4</sub>")
# errorbars(df_ch4.loc["2012-01-01":], "InTEM", color_ch4, None, "CH<sub>4</sub>", showlegend=False)
errorbars(df_ch4, "InTEM", color_ch4, None, "Methane")
fig.add_trace(go.Scatter(
x=df_ch4.index,
y=df_ch4["Invent"],
line=dict(color=color_ch4[0], dash="dot", width=5),
showlegend=False,
hovertemplate = 'Inventory %{x|%Y}: %{y:.0f} Gt yr⁻¹<extra></extra>',
))
errorbars(df_n2o, "InTEM", color_n2o, None, "Nitrous oxide")
# errorbars(df_n2o[:"2011-01-01"], "InTEM", color_n2o, None, "N<sub>2</sub>O")
# errorbars(df_n2o["2012-01-01":], "InTEM", color_n2o, None, "N<sub>2</sub>O", showlegend=False)
fig.add_trace(go.Scatter(
x=df_n2o.index,
y=df_n2o["Invent"],
line=dict(color=color_n2o[0], dash="dot", width=4),
showlegend=False,
hovertemplate = 'Inventory %{x|%Y}: %{y:.0f} Gt yr⁻¹<extra></extra>',
#name="N<sub>2</sub>O"
))
errorbars(df_fgas["2012-01-01":], "InTEM", color_fgas, None, "F-gases")
fig.add_trace(go.Scatter(
x=df_fgas.index,
y=df_fgas["Invent"],
line=dict(color=color_fgas[0], dash="dot", width=4),
showlegend=False,
hovertemplate = 'Inventory %{x|%Y}: %{y:.0f} Gt yr⁻¹<extra></extra>',
#name="F-gases"
))
# Add fake line for InTEM
fig.add_trace(go.Scatter(
x=[pd.Timestamp("1900-01-01"), pd.Timestamp("1900-01-02")],
y=[0., 0.],
line=dict(color="black", dash=None),
marker=dict(opacity=0., size=0),
showlegend=True,
name="Atmospheric data"
))
# Add fake line for inventory legend
fig.add_trace(go.Scatter(
x=[pd.Timestamp("1900-01-01"), pd.Timestamp("1900-01-02")],
y=[0., 0.],
line=dict(color="black", dash="dot", width=4),
marker=dict(opacity=0., size=0),
showlegend=True,
name="Inventory (2021)"
))
fig.update_layout(
# title={"text": "UK non-CO<sub>2</sub> reenhouse gas emissions 2010 - 2020",
# "xanchor": "left",
# "x": 0.01},
yaxis_title="CO<sub>2</sub>-equivalent emissions (Gt yr⁻¹)",
template="none",
autosize=False,
width=1000,
height=600,
legend=dict(
yanchor="top",
y=0.77,
xanchor="right",
x=0.99,
traceorder="normal"),
margin=dict(l=100, r=50, t=50, b=50),
# paper_bgcolor='rgba(0,0,0,0)',
# plot_bgcolor='rgba(0,0,0,0)'
)
fig.layout.font.size=20
fig.layout.font.family="Arial"
fig.update_xaxes(range=[pd.Timestamp("1990-01-01"),
pd.Timestamp("2020-01-01")])
fig.update_yaxes(range=[0,
153])
# Add UKMO logo
fig.add_layout_image(
dict(
source='data:image/png;base64,{}'.format(mo_logo.decode()),
xref="x domain",
yref="y domain",
x=1.015, y=0.9,
sizex=0.25,
sizey=0.3,
xanchor="right", yanchor="top"
)
)
# Add UoB logo
fig.add_layout_image(
dict(
source='data:image/png;base64,{}'.format(uob_logo.decode()),
xref="x domain",
yref="y domain",
x=0.99, y=0.99,
sizex=0.2,
sizey=0.3,
xanchor="right", yanchor="top"
)
)
# Add shading to 2-site period
fig.add_vrect(x0="1990-01-01", x1="2011-06-01",
#annotation_text=None, annotation_position="left",
fillcolor="grey", opacity=0.1, line_width=0)
# Text annotation denoting period
fig.add_annotation(
xref="x",
yref="y",
x="2014-01-01",
y=45,
align="left",
text="DECC network",
showarrow=False,
font=dict(
family="Arial",
size=15,
color="Grey",
)
)
fig.add_annotation(
xref="x",
yref="y",
x="2011-06-01",
arrowwidth=2,
arrowcolor="grey",
align="right",
y=40,
ax=150,
ay=0,
arrowside="start",
text=None
)
# Text annotation denoting 2-site period
fig.add_annotation(
xref="x",
yref="y",
x="2008-09-01",
y=40,
align="right",
text="Mace Head, Cabauw",
showarrow=False,
font=dict(
family="Arial",
size=15,
color="Grey",
)
)
fig.add_annotation(
xref="x",
yref="y",
x="2011-06-01",
arrowwidth=2,
arrowcolor="grey",
align="right",
y=35,
ax=-150,
ay=0,
arrowside="start",
text=None
)
# # Text annotation for CH4
# fig.add_annotation(
# xref="paper",
# yref="y",
# x=1.01,
# y=df_ch4.loc["2020-01-01", "InTEM"],
# xanchor="left",
# align="left",
# # text="<b>CH<sub>4</sub></b>",
# text="<b>Methane</b>",
# showarrow=False,
# font=dict(
# family="Arial",
# size=20,
# color=color_ch4[0]
# )
# )
# # Text annotation for N2O
# fig.add_annotation(
# xref="paper",
# yref="y",
# x=1.01,
# y=df_n2o.loc["2020-01-01", "InTEM"],
# xanchor="left",
# align="left",
# # text="<b>CH<sub>4</sub></b>",
# text="<b>Nitrous<br>oxide</b>",
# showarrow=False,
# font=dict(
# family="Arial",
# size=20,
# color=color_n2o[0]
# )
# )
# # Text annotation for F-gases
# fig.add_annotation(
# xref="paper",
# yref="y",
# x=1.01,
# y=df_fgas.loc["2020-01-01", "InTEM"],
# xanchor="left",
# align="left",
# # text="<b>CH<sub>4</sub></b>",
# text="<b>F-gases</b>",
# showarrow=False,
# font=dict(
# family="Arial",
# size=20,
# color=color_fgas[0]
# )
# )
fig.write_image("InTEM_CO2e_2021.pdf")
fig.write_image("InTEM_CO2e_2021.png")
fig.write_image("InTEM_CO2e_2021.svg")
fig.write_html("InTEM_CO2e_2021.html")
fig.show()
def intem_by_year(year):
Intem_new_year = weighted_temporal_mean(ds_flux, "flux_prior")
intem = Intem_new_year[dict(time=year)] * area
return intem
new_agri2012 = read_invent_ch4("2012", "agric")
new_total2012 = read_invent_ch4("2012", "total")
new_agri_flux2012 = 100*(new_agri2012.flux / new_total2012.flux)
new_agri_flux2012_clip = np.clip(new_agri_flux2012, 0, 100)
new_agri_flux2012_clip.plot()
<matplotlib.collections.QuadMesh at 0x7fd20b0eecd0>
years = ["2012", "2013", "2014", "2015"]
species = ["1. Energy"]
dataframe = pd.DataFrame(index = years, columns = species)
for name in years:
a = read_invent_ch4(name, "domcom")
b = read_invent_ch4(name, "energyprod")
c = read_invent_ch4(name, "offshore")
d = read_invent_ch4(name, "othertrans")
e = read_invent_ch4(name, "roadtrans")
f = read_invent_ch4(name, "total")
fract = a.flux + b.flux + c.flux + d.flux + e.flux / f.flux
test = fract.reindex_like(Intem2012, method='nearest', tolerance=0.01)
test1 = test.sum()
test2 = test1.to_pandas()
#dataframe = pd.concat((test2, dataframe))
number = 0
#y = 0
while number < 4:
te = test * intem_by_year(number)
te = te.sum()
te = te * 16 * 31536000 * 28 / 10000000000000
te = te.to_pandas()
dataframe.loc[years[number]] = te
#pd.DataFrame(te)
#pd.concat([e, te])
number += 1
#y += 1
dataframe
#te = xr.concat((te12, te13, te14, te15), dim="time")
#te = te * 16 * 31536000 * 28 / 10000000000000
#te = te.to_pandas()
| 1. Energy | |
|---|---|
| 2012 | 21660.406571 |
| 2013 | 25066.920315 |
| 2014 | 25012.136709 |
| 2015 | 26557.993559 |
def energy_intem(year, time):
a = read_invent_ch4(year, "domcom")
b = read_invent_ch4(year, "energyprod")
c = read_invent_ch4(year, "offshore")
d = read_invent_ch4(year, "othertrans")
e = read_invent_ch4(year, "roadtrans")
f = read_invent_ch4(year, "total")
fract = a.flux + b.flux + c.flux + d.flux + e.flux / f.flux
test = fract.reindex_like(Intem2012, method='nearest', tolerance=0.01)
tenerg = test * intem_by_year(time)
te = tenerg.sum()
te = te * 16 * 31536000 * 28 / 10000000000000
te = te.to_pandas()
return te
twaste
time
2012-01-01 27.069449
2013-01-01 24.914120
2014-01-01 23.662646
2015-01-01 23.043143
2016-01-01 23.358710
2017-01-01 23.216320
2018-01-01 23.190191
2019-01-01 23.189085
2020-01-01 23.473584
dtype: float64
ch4_gt_all
| 1. Energy | 1. Energy_std | 2. Industrial processes | 2. Industrial processes_std | 3. Agriculture | 3. Agriculture_std | 4. Land use, land-use change and forestry | 4. Land use, land-use change and forestry_std | 5. Waste | 5. Waste_std | |
|---|---|---|---|---|---|---|---|---|---|---|
| Year | ||||||||||
| 1990-01-01 | 17.278187 | 2.879698 | 0.134860 | 0.022477 | 13.534169 | 2.255695 | 2.191062 | 0.365177 | 29.021722 | 4.836954 |
| 1991-01-01 | 17.340445 | 2.746224 | 0.129882 | 0.020569 | 13.226288 | 2.094661 | 2.167182 | 0.343219 | 29.016205 | 4.595327 |
| 1992-01-01 | 15.512368 | 2.559541 | 0.123061 | 0.020305 | 12.047561 | 1.987848 | 1.958975 | 0.323231 | 26.358035 | 4.349076 |
| 1993-01-01 | 15.246390 | 2.454297 | 0.121500 | 0.019559 | 12.454668 | 2.004898 | 2.028496 | 0.326538 | 27.548946 | 4.434708 |
| 1994-01-01 | 14.158017 | 1.916587 | 0.147697 | 0.019994 | 14.732562 | 1.994364 | 2.385312 | 0.322903 | 32.696412 | 4.426152 |
| 1995-01-01 | 13.336143 | 1.761377 | 0.111747 | 0.014759 | 13.367396 | 1.765505 | 2.184826 | 0.288562 | 30.359888 | 4.009797 |
| 1996-01-01 | 15.447600 | 1.796233 | 0.152056 | 0.017681 | 16.668264 | 1.938170 | 2.667912 | 0.310222 | 37.304168 | 4.337694 |
| 1997-01-01 | 12.543075 | 1.687409 | 0.117587 | 0.015819 | 14.582981 | 1.961836 | 2.350538 | 0.316216 | 32.845819 | 4.418720 |
| 1998-01-01 | 12.473152 | 1.729471 | 0.101749 | 0.014108 | 16.048882 | 2.225265 | 2.573537 | 0.356835 | 35.442680 | 4.914321 |
| 1999-01-01 | 10.829801 | 1.748309 | 0.087592 | 0.014140 | 15.672819 | 2.530141 | 2.521386 | 0.407040 | 33.328401 | 5.380370 |
| 2000-01-01 | 8.584429 | 1.338433 | 0.070974 | 0.011066 | 13.272327 | 2.069341 | 2.211257 | 0.344766 | 27.941013 | 4.356395 |
| 2001-01-01 | 9.810942 | 1.299166 | 0.084965 | 0.011251 | 15.512830 | 2.054210 | 2.722726 | 0.360544 | 33.188537 | 4.394829 |
| 2002-01-01 | 8.858090 | 1.302660 | 0.082730 | 0.012166 | 14.555781 | 2.140556 | 2.597713 | 0.382017 | 31.025685 | 4.562601 |
| 2003-01-01 | 9.192613 | 1.313230 | 0.107263 | 0.015323 | 16.922996 | 2.417571 | 3.012305 | 0.430329 | 33.484823 | 4.783546 |
| 2004-01-01 | 8.868360 | 1.213125 | 0.097379 | 0.013321 | 16.920220 | 2.314558 | 2.973267 | 0.406720 | 30.500774 | 4.172276 |
| 2005-01-01 | 8.142615 | 1.032163 | 0.088883 | 0.011267 | 17.844822 | 2.262020 | 3.142094 | 0.398294 | 30.421585 | 3.856257 |
| 2006-01-01 | 7.803978 | 1.082849 | 0.092805 | 0.012877 | 18.007220 | 2.498610 | 3.235929 | 0.449005 | 29.380068 | 4.076660 |
| 2007-01-01 | 8.094752 | 1.081787 | 0.107448 | 0.014359 | 19.436413 | 2.597493 | 3.526772 | 0.471320 | 29.594614 | 3.955041 |
| 2008-01-01 | 7.881507 | 1.114945 | 0.085181 | 0.012050 | 19.117827 | 2.704473 | 3.581007 | 0.506582 | 26.734478 | 3.781951 |
| 2009-01-01 | 7.339090 | 1.163025 | 0.086598 | 0.013723 | 17.895264 | 2.835861 | 3.390638 | 0.537314 | 22.528409 | 3.570076 |
| 2010-01-01 | 8.776553 | 1.049827 | 0.109436 | 0.013090 | 22.022631 | 2.634286 | 4.162182 | 0.497869 | 23.449198 | 2.804928 |
| 2011-01-01 | 7.259141 | 1.090969 | 0.085128 | 0.012794 | 18.865598 | 2.835292 | 3.598894 | 0.540874 | 18.631239 | 2.800071 |
| 2012-01-01 | 4.150356 | 0.007887 | 1.709978 | 0.008203 | 31.015892 | 0.007540 | 5.301648 | 0.319376 | 27.069449 | 1.559032 |
| 2013-01-01 | 4.046147 | 0.006812 | 1.727763 | 0.008069 | 31.779851 | 0.006665 | 5.097186 | 0.297145 | 24.914120 | 1.267578 |
| 2014-01-01 | 3.985527 | 0.005130 | 1.686796 | 0.006256 | 32.548314 | 0.005236 | 5.350233 | 0.235693 | 23.662646 | 0.900622 |
| 2015-01-01 | 4.005459 | 0.005207 | 1.647669 | 0.004212 | 33.126938 | 0.005270 | 5.236107 | 0.241295 | 23.043143 | 0.884316 |
| 2016-01-01 | 3.797205 | 0.005434 | 1.406961 | 0.005269 | 34.159907 | 0.005874 | 5.362243 | 0.274347 | 23.358710 | 0.962408 |
| 2017-01-01 | 4.051529 | 0.005232 | 1.614963 | 0.004192 | 34.237765 | 0.005279 | 5.098931 | 0.247521 | 23.216320 | 0.888065 |
| 2018-01-01 | 4.070484 | 0.005765 | 1.612369 | 0.003556 | 33.997470 | 0.005787 | 5.398052 | 0.277470 | 23.190191 | 0.985230 |
| 2019-01-01 | 4.065171 | 0.005234 | 1.630729 | 0.004419 | 34.030278 | 0.005262 | 5.185956 | 0.255466 | 23.189085 | 0.891994 |
| 2020-01-01 | 4.031308 | 0.005198 | 1.760872 | 0.004379 | 34.081194 | 0.005265 | 5.130561 | 0.264462 | 23.473584 | 0.859323 |
| 2021-01-01 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN |
#Invent_total.drop(["1990", "1991", "1992", "1993", "1994", "1995", "1996", "1997", "1998", "1999",
# "2000", "2001", "2002", "2003", "2004", "2005", "2006", "2007", "2008", "2009",
# "2010", "2011"], inplace=True)
InTEM_total.drop(["1990", "1991", "1992", "1993", "1994", "1995", "1996", "1997", "1998", "1999",
"2000", "2001", "2002", "2003", "2004", "2005", "2006", "2007", "2008", "2009",
"2010", "2011"], inplace=True)
df_fgas.drop(["1990", "1991", "1992", "1993", "1994", "1995", "1996", "1997", "1998", "1999",
"2000", "2001", "2002", "2003", "2004", "2005", "2006", "2007", "2008", "2009",
"2010", "2011"], inplace=True)
Here is a map of the DECC network: